@model FunnelWeb.Web.Areas.Admin.Views.Install.UpgradeModel
@{
  ViewBag.Title = "FunnelWeb Installation Report";
  Layout = "~/Areas/Admin/Views/Shared/_Private.cshtml";
}

<h1>
  FunnelWeb Upgrade Report
</h1>
    
@if (Model.Results.ApplicationUpgradeResult.OriginalVersion == Model.Results.ApplicationUpgradeResult.UpgradedVersion) {
  <p class='good'>
    FunnelWeb application database was already up to date. Feel free to review the logs below before continuing.
  </p>
} else if (Model.Results.ApplicationUpgradeResult.Successful) {
  <p class='good'>
    The upgrade to version @Model.Results.ApplicationUpgradeResult.UpgradedVersion completed successfully. Feel free to review the logs below before continuing.
  </p>
} else {
  <p class='bad'>The upgrade failed. Please review the logs below to resolve the issue.</p>
}

@if (Model.Results.ExtensionsUpgradeResults.Any(e => e.OriginalVersion != e.UpgradedVersion)) { 

  <h1>Extensions Upgrade Report</h1>
    
  foreach (var extensionReport in Model.Results.ExtensionsUpgradeResults.Where(e => e.OriginalVersion != e.UpgradedVersion)) { 
    if (extensionReport.Successful)
    {
      <p class='good'>
        The upgrade of @extensionReport.Name to version @extensionReport.UpgradedVersion completed successfully. Feel free to review the logs below before continuing.
      </p>
    } else {
      <p class='bad'>The upgrade failed. Please review the logs below to resolve the issue.</p>
    }
  }
}
<p class='important'>
  @Html.AdminActionLink("Back to upgrade page", "Index", "Install")
</p>

<h2>Log</h2>
<ol>
  @MvcHtmlString.Create(Model.Log)
</ol>

@if (Model.Results.ApplicationUpgradeResult.Successful == false && Model.Results.ApplicationUpgradeResult.Error != null)
{
  <h2>FunnelWeb Upgrade Exception Details</h2>
  <pre>@MvcHtmlString.Create(Model.Results.ApplicationUpgradeResult.Error.ToString())</pre>
}

@foreach (var extensionResults in Model.Results.ExtensionsUpgradeResults) {
  if (extensionResults.Successful == false && extensionResults.Error != null)
  {
    <h2>@extensionResults.Name Upgrade Exception Details</h2>
    <pre>@MvcHtmlString.Create(extensionResults.Error.ToString())</pre>
  }
}